package com.chenfan.mcn.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.mcn.dao.PurchaseContractMapper;
import com.chenfan.mcn.extension.Res;
import com.chenfan.common.extension.mybatisplus.enhanced.EnhancedService;
import com.chenfan.mcn.model.McnPage;
import com.chenfan.mcn.model.PurchaseContract;
import com.chenfan.mcn.model.dto.ChooseExecutionDTO;
import com.chenfan.mcn.model.dto.PurchaseContractDTO;
import com.chenfan.mcn.model.dto.PurchaseContractSearchDTO;
import com.chenfan.mcn.model.vo.ChooseExecution;
import com.chenfan.mcn.model.vo.PurchaseContractVO;
import com.chenfan.mcn.model.vo.PurchaseSimpleVO;
import com.chenfan.mcn.model.vo.PurchaseVO;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author lizhejin
 * @since 2021-02-26
 */
public interface PurchaseContractService extends EnhancedService<PurchaseContractMapper, PurchaseContract> {

    /**
     * 新增/编辑采购合同
     *
     * @param purchaseContract {@link PurchaseContractDTO}
     * @return long
     */
    Long saveData(PurchaseContractDTO purchaseContract);

    /**
     * 查询指定收入合同下关联的采购合同单号
     *
     * @param incomeContractCode {@link String}
     * @return {@link List}
     */
    List<PurchaseSimpleVO> getPurchaseByContract(@RequestParam String incomeContractCode);

    /**
     * 修改采购合同状态
     *
     * @param id     {@link Long}
     * @param status {@link Integer}
     * @return {@link Boolean}
     */
    boolean changeStatus(Long id, Integer status);

    /**
     * 详情
     *
     * @param page 分页
     * @param id   {@link Long}
     * @return {@link Res <PurchaseContractVO>}
     */
    PurchaseContractVO info(McnPage<PurchaseContractVO> page, Long id);

    /**
     * 分页数据
     *
     * @param page                      {@link McnPage}
     * @param purchaseContractSearchDTO {@link PurchaseContractSearchDTO}
     * @return
     */
    Page<PurchaseVO> getList(McnPage<PurchaseVO> page, PurchaseContractSearchDTO purchaseContractSearchDTO);

    /**
     * 采购合同列表导出
     *
     * @param purchaseContractSearchDTO {@link PurchaseContractSearchDTO}
     * @param response                  {@link HttpServletResponse}
     * @throws Exception
     */
    void exportExcel(PurchaseContractSearchDTO purchaseContractSearchDTO, HttpServletResponse response) throws Exception;

    /**
     * 根据采购合同编号获取采购合同
     *
     * @param contractCode
     * @return PurchaseContract
     */
    PurchaseContract getByCode(String contractCode);

    /**
     * 采购合同关联执行单弹窗
     *
     * @param page         分页
     * @param executionDTO 入参
     * @return
     */
    Page<ChooseExecution> getExecutionOrders(McnPage<ChooseExecution> page, ChooseExecutionDTO executionDTO);

    /**
     * 详情列表导出
     *
     * @param id       {@link Long}
     * @param response {@link HttpServletResponse}
     * @throws Exception
     */
    void infoExport(Long id, HttpServletResponse response) throws Exception;
}
